package org.sensation.server.send;

import java.io.IOException;
import java.net.InetSocketAddress;

import org.sensation.file.channel.FileReadChannel;
import org.sensation.server.file.SensationFileSendServer;
import org.sensation.server.operation.request.Command;

public class CommanderWithServerContact {
	private Contactor contact;
	private Command command;
	private SensationFileSendServer sendServer;
	
	public CommanderWithServerContact(Contactor contact, Command command) {
		super();
		this.contact = contact;
		this.command = command;
	}

	public Command setup() throws IOException, ClassNotFoundException {
		command.setCommand("setup");
		return contact.call(command);
	}

	public void sendingFile(FileReadChannel readChannel) throws IOException {
		int destinationServerPort = command.getDestinationServerPort();
		
		sendServer = new SensationFileSendServer(
					new InetSocketAddress(destinationServerPort),
					readChannel);
		sendServer.start();
	}

	public Command requestToCompleteOnFileTransfer() {
		
		return null;
		
	}

	public void complete() {
		
	}

}
